﻿using Fishing.ViewModel;
using Microsoft.Extensions.DependencyInjection;
using System.Windows.Controls;
using System.Windows.Input;

namespace Fishing.Controls
{
    public partial class Updater : UserControl
    {
        private readonly UpdaterViewModel _updaterVm;

        public Updater()
        {
            InitializeComponent();

            _updaterVm = App.Services.GetRequiredService<UpdaterViewModel>();

            DataContext = _updaterVm;
        }

        public UpdaterViewModel GetViewModel()
            => _updaterVm;

        private void Updater_OnPreviewKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Space)
            {
                return;
            }

            _updaterVm.SetLongPressFail();
        }
    }
}